<? 
$user_id = $_SESSION['SESS_MEMBER_ID'];
$sql3 	= "SELECT * FROM menu,link where menu.parent=0 and link.mid=menu.mid and link.user_id='$user_id' order by menu.rank";
$result = $dbcn->select($sql3);
//$result = mysql_query("SELECT * FROM menu,link where menu.parent=0 and link.mid=menu.mid and link.user_id='$user_id' order by menu.rank");
?>
<ul class="nav navbar-top-links navbar-right">
	<?
	for ($i = 0; $i < count($result); $i++)
	{
		$row = array();
		$row = $result[$i];
			
		$mid=$row['mid'];
		//$path="$row[path]&mid=".$mid;
		$img_path="background-image: url(".$row['img_path'].")";
		$title=$row['title'];
		$level_id1=$row['level_id'];
		$m_id1=$_GET['mid'];
		if($m_id1==$mid)
		{
			$act_id="active";
		}
		else
		{
			$act_id="";
		}

		//$result_page=mysql_query("select * from menu,link where menu.mid=link.mid and link.user_id='$user_id' and menu.parent='$mid' and menu.rank=1");
		//$numb=mysql_num_rows($result_page);

		$sql4 = "select * from menu,link where menu.mid=link.mid and link.user_id='$user_id' and menu.parent='$mid' and menu.rank=1";
		$result_page = $dbcn->select($sql4);
		$numb = $dbcn->chknum($sql4);
		if($numb==0)
		{
			$path="$row[path]&mid=".$mid;
		}
		else
		{
			//$row_page=mysql_fetch_array($result_page);

			$mid1=$result_page[0]['mid'];
			$path1=$result_page[0]['path'];

			//$result_page1=mysql_query("select * from menu,link where menu.mid=link.mid and link.user_id='$user_id' and menu.parent='$mid1' and menu.rank=1");

			$sql5 = "select * from menu,link where menu.mid=link.mid and link.user_id='$user_id' and menu.parent='$mid1' and menu.rank=1";
			$result_page1 = $dbcn->select($sql5);
			$numb1 = $dbcn->chknum($sql5);
			//$numb1=mysql_num_rows($result_page1);

			//$row_page1=mysql_fetch_array($result_page1);

			$path2 = $result_page1[0]['path'];
			$smid = $result_page1[0]['mid'];

			if($numb1>0)
			{
				$path="$path2&mid=".$mid."&smid=".$smid;
			}
			else
			{
				$path="$path1&mid=".$mid."&smid=".$mid1;
			}
		}
		if($level_id1!=0)
		{
			?>
	<li><a class="tab" id="<? echo $act_id;?>" HREF="<? echo $path; ?>"
		title=""><? echo $title;?> </a></li>
	<?}
	?>
	<?	}   ?>
	<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown"
		href="#"> <i class="fa fa-user fa-fw"></i> <i class="fa fa-caret-down"></i>
	</a>
		<ul class="dropdown-menu dropdown-user">
			<li>
				<a href="Class_Creation/" target="_blank"><i class="fa fa-user fa-fw"></i>Create Classes</a>
			</li>
			<li>
				<a href="#"><i class="fa fa-user fa-fw"></i> User Profile</a>
			</li>
			<li class="divider"></li>
			<li><a href="process/processLogout.php"><i
					class="fa fa-sign-out fa-fw"></i> Logout</a>
			</li>
		</ul> <!-- /.dropdown-user -->
	</li>
</ul>
